import request from "@/api/request.js";

//get all
export const getAllUnitService = () => {
  return request.get("/api-self/users/unit/getUnits");
};

//add
export const addUnitService = dataObj => {
  const params = new URLSearchParams();
  for (let key in dataObj) {
    params.append(key, dataObj[key]);
  }
  let queryString = params.toString();
  let url = `/api-self/users/unit/addUnit?${queryString}`;
  return request.post(url);
};

//del
export const delUnitService = dataObj => {
  const params = new URLSearchParams();
  for (let key in dataObj) {
    params.append(key, dataObj[key]);
  }
  let queryString = params.toString();
  let url = `/api-self/users/unit/deleteUnit?${queryString}`;
  return request.delete(url);
};

//edit
export const editUnitService = dataObj => {
  const params = new URLSearchParams();
  for (let key in dataObj) {
    params.append(key, dataObj[key]);
  }
  let queryString = params.toString();
  let url = `/api-self/users/unit/updateUnit?${queryString}`;
  return request.put(url);
};
